# -*- coding: utf-8 -*-
from django.db import migrations, models
from django.utils import timezone
from datetime import datetime


def add_default_data(apps, schema_editor):
    # 获取模型
    Department = apps.get_model("system", "Department")
    Dictionary = apps.get_model("system", "Dictionary")
    DictionaryItem = apps.get_model("system", "DictionaryItem")
    Menu = apps.get_model("system", "Menu")
    Role = apps.get_model("system", "Role")
    RoleMenu = apps.get_model("system", "RoleMenu")
    User = apps.get_model("system", "User")
    UserRole = apps.get_model("system", "UserRole")
    SysConfig = apps.get_model("system", "SysConfig")
    Notice = apps.get_model("system", "Notice")
    UserNotice = apps.get_model("system", "UserNotice")

    # 插入部门数据
    Department.objects.create(
        id=1,
        name="有来技术",
        code="YOULAI",
        parent_id=0,
        tree_path="0",
        sort=1,
        status=1,
        create_by=1,
        create_time=None,
        update_by=1,
        update_time=timezone.now(),
        is_deleted=0
    )
    Department.objects.create(
        id=2,
        name="研发部门",
        code="RD001",
        parent_id=1,
        tree_path="0,1",
        sort=1,
        status=1,
        create_by=2,
        create_time=None,
        update_by=2,
        update_time=timezone.now(),
        is_deleted=0
    )
    Department.objects.create(
        id=3,
        name="测试部门",
        code="QA001",
        parent_id=1,
        tree_path="0,1",
        sort=1,
        status=1,
        create_by=2,
        create_time=None,
        update_by=2,
        update_time=timezone.now(),
        is_deleted=0
    )

    # 插入字典数据
    Dictionary.objects.create(
        id=1,
        dict_code="gender",
        name="性别",
        status=1,
        remark=None,
        create_time=timezone.now(),
        create_by=1,
        update_time=timezone.now(),
        update_by=1,
        is_deleted=0
    )
    Dictionary.objects.create(
        id=2,
        dict_code="notice_type",
        name="通知类型",
        status=1,
        remark=None,
        create_time=timezone.now(),
        create_by=1,
        update_time=timezone.now(),
        update_by=1,
        is_deleted=0
    )
    Dictionary.objects.create(
        id=3,
        dict_code="notice_level",
        name="通知级别",
        status=1,
        remark=None,
        create_time=timezone.now(),
        create_by=1,
        update_time=timezone.now(),
        update_by=1,
        is_deleted=0
    )

    # 插入字典项数据
    DictionaryItem.objects.create(
        id=1,
        dict_code="gender",
        value="1",
        label="男",
        tag_type="primary",
        status=1,
        sort=1,
        remark=None,
        create_time=timezone.now(),
        create_by=1,
        update_time=timezone.now(),
        update_by=1
    )
    DictionaryItem.objects.create(
        id=2,
        dict_code="gender",
        value="2",
        label="女",
        tag_type="danger",
        status=1,
        sort=2,
        remark=None,
        create_time=timezone.now(),
        create_by=1,
        update_time=timezone.now(),
        update_by=1
    )
    DictionaryItem.objects.create(
        id=3,
        dict_code="gender",
        value="0",
        label="保密",
        tag_type="info",
        status=1,
        sort=3,
        remark=None,
        create_time=timezone.now(),
        create_by=1,
        update_time=timezone.now(),
        update_by=1
    )
    DictionaryItem.objects.create(
        id=4,
        dict_code="notice_type",
        value="1",
        label="系统升级",
        tag_type="success",
        status=1,
        sort=1,
        remark="",
        create_time=timezone.now(),
        create_by=1,
        update_time=timezone.now(),
        update_by=1
    )
    DictionaryItem.objects.create(
        id=5,
        dict_code="notice_type",
        value="2",
        label="系统维护",
        tag_type="primary",
        status=1,
        sort=2,
        remark="",
        create_time=timezone.now(),
        create_by=1,
        update_time=timezone.now(),
        update_by=1
    )
    DictionaryItem.objects.create(
        id=6,
        dict_code="notice_type",
        value="3",
        label="安全警告",
        tag_type="danger",
        status=1,
        sort=3,
        remark="",
        create_time=timezone.now(),
        create_by=1,
        update_time=timezone.now(),
        update_by=1
    )
    DictionaryItem.objects.create(
        id=7,
        dict_code="notice_type",
        value="4",
        label="假期通知",
        tag_type="success",
        status=1,
        sort=4,
        remark="",
        create_time=timezone.now(),
        create_by=1,
        update_time=timezone.now(),
        update_by=1
    )
    DictionaryItem.objects.create(
        id=8,
        dict_code="notice_type",
        value="5",
        label="公司新闻",
        tag_type="primary",
        status=1,
        sort=5,
        remark="",
        create_time=timezone.now(),
        create_by=1,
        update_time=timezone.now(),
        update_by=1
    )
    DictionaryItem.objects.create(
        id=9,
        dict_code="notice_type",
        value="99",
        label="其他",
        tag_type="info",
        status=1,
        sort=99,
        remark="",
        create_time=timezone.now(),
        create_by=1,
        update_time=timezone.now(),
        update_by=1
    )
    DictionaryItem.objects.create(
        id=10,
        dict_code="notice_level",
        value="L",
        label="低",
        tag_type="info",
        status=1,
        sort=1,
        remark="",
        create_time=timezone.now(),
        create_by=1,
        update_time=timezone.now(),
        update_by=1
    )
    DictionaryItem.objects.create(
        id=11,
        dict_code="notice_level",
        value="M",
        label="中",
        tag_type="warning",
        status=1,
        sort=2,
        remark="",
        create_time=timezone.now(),
        create_by=1,
        update_time=timezone.now(),
        update_by=1
    )
    DictionaryItem.objects.create(
        id=12,
        dict_code="notice_level",
        value="H",
        label="高",
        tag_type="danger",
        status=1,
        sort=3,
        remark="",
        create_time=timezone.now(),
        create_by=1,
        update_time=timezone.now(),
        update_by=1
    )

    # 插入菜单数据
    Menu.objects.create(
        id=1,
        parent_id=0,
        tree_path="0",
        name="系统管理",
        type=2,
        route_name="",
        route_path="/system",
        component="Layout",
        perm=None,
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=1,
        icon="system",
        redirect="/system/user",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=2,
        parent_id=1,
        tree_path="0,1",
        name="用户管理",
        type=1,
        route_name="User",
        route_path="user",
        component="system/user/index",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=1,
        icon="el-icon-User",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=3,
        parent_id=1,
        tree_path="0,1",
        name="角色管理",
        type=1,
        route_name="Role",
        route_path="role",
        component="system/role/index",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=2,
        icon="role",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=4,
        parent_id=1,
        tree_path="0,1",
        name="菜单管理",
        type=1,
        route_name="SysMenu",
        route_path="menu",
        component="system/menu/index",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=3,
        icon="menu",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=5,
        parent_id=1,
        tree_path="0,1",
        name="部门管理",
        type=1,
        route_name="Dept",
        route_path="dept",
        component="system/dept/index",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=4,
        icon="tree",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=6,
        parent_id=1,
        tree_path="0,1",
        name="字典管理",
        type=1,
        route_name="Dict",
        route_path="dict",
        component="system/dict/index",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=5,
        icon="dict",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=20,
        parent_id=0,
        tree_path="0",
        name="多级菜单",
        type=2,
        route_name=None,
        route_path="/multi-level",
        component="Layout",
        perm=None,
        always_show=1,
        keep_alive=0,
        visible=1,
        sort=9,
        icon="cascader",
        redirect="",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=21,
        parent_id=20,
        tree_path="0,20",
        name="菜单一级",
        type=1,
        route_name=None,
        route_path="multi-level1",
        component="demo/multi-level/level1",
        perm=None,
        always_show=1,
        keep_alive=0,
        visible=1,
        sort=1,
        icon="",
        redirect="",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=22,
        parent_id=21,
        tree_path="0,20,21",
        name="菜单二级",
        type=1,
        route_name=None,
        route_path="multi-level2",
        component="demo/multi-level/children/level2",
        perm=None,
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=1,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=23,
        parent_id=22,
        tree_path="0,20,21,22",
        name="菜单三级-1",
        type=1,
        route_name=None,
        route_path="multi-level3-1",
        component="demo/multi-level/children/children/level3-1",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=1,
        icon="",
        redirect="",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=24,
        parent_id=22,
        tree_path="0,20,21,22",
        name="菜单三级-2",
        type=1,
        route_name=None,
        route_path="multi-level3-2",
        component="demo/multi-level/children/children/level3-2",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=2,
        icon="",
        redirect="",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=26,
        parent_id=0,
        tree_path="0",
        name="平台文档",
        type=2,
        route_name="",
        route_path="/doc",
        component="Layout",
        perm=None,
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=8,
        icon="document",
        redirect="https://juejin.cn/post/7228990409909108793",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=30,
        parent_id=26,
        tree_path="0,26",
        name="平台文档(外链)",
        type=3,
        route_name=None,
        route_path="https://juejin.cn/post/7228990409909108793",
        component="",
        perm=None,
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=2,
        icon="document",
        redirect="",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=31,
        parent_id=2,
        tree_path="0,1,2",
        name="用户新增",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:user:add",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=1,
        icon="",
        redirect="",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=32,
        parent_id=2,
        tree_path="0,1,2",
        name="用户编辑",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:user:edit",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=2,
        icon="",
        redirect="",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=33,
        parent_id=2,
        tree_path="0,1,2",
        name="用户删除",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:user:delete",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=3,
        icon="",
        redirect="",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=36,
        parent_id=0,
        tree_path="0",
        name="组件封装",
        type=2,
        route_name=None,
        route_path="/component",
        component="Layout",
        perm=None,
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=10,
        icon="menu",
        redirect="",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=37,
        parent_id=36,
        tree_path="0,36",
        name="富文本编辑器",
        type=1,
        route_name=None,
        route_path="wang-editor",
        component="demo/wang-editor",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=2,
        icon="",
        redirect="",
        create_time=None,
        update_time=None,
        params=None
    )
    Menu.objects.create(
        id=38,
        parent_id=36,
        tree_path="0,36",
        name="图片上传",
        type=1,
        route_name=None,
        route_path="upload",
        component="demo/upload",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=3,
        icon="",
        redirect="",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=39,
        parent_id=36,
        tree_path="0,36",
        name="图标选择器",
        type=1,
        route_name=None,
        route_path="icon-selector",
        component="demo/icon-selector",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=4,
        icon="",
        redirect="",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=40,
        parent_id=0,
        tree_path="0",
        name="接口文档",
        type=2,
        route_name=None,
        route_path="/api",
        component="Layout",
        perm=None,
        always_show=1,
        keep_alive=0,
        visible=1,
        sort=7,
        icon="api",
        redirect="",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=41,
        parent_id=40,
        tree_path="0,40",
        name="Apifox",
        type=1,
        route_name=None,
        route_path="apifox",
        component="demo/api/apifox",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=1,
        icon="api",
        redirect="",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=70,
        parent_id=3,
        tree_path="0,1,3",
        name="角色新增",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:role:add",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=2,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=71,
        parent_id=3,
        tree_path="0,1,3",
        name="角色编辑",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:role:edit",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=3,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=72,
        parent_id=3,
        tree_path="0,1,3",
        name="角色删除",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:role:delete",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=4,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=73,
        parent_id=4,
        tree_path="0,1,4",
        name="菜单新增",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:menu:add",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=1,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=74,
        parent_id=4,
        tree_path="0,1,4",
        name="菜单编辑",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:menu:edit",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=3,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=75,
        parent_id=4,
        tree_path="0,1,4",
        name="菜单删除",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:menu:delete",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=3,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=76,
        parent_id=5,
        tree_path="0,1,5",
        name="部门新增",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:dept:add",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=1,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=77,
        parent_id=5,
        tree_path="0,1,5",
        name="部门编辑",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:dept:edit",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=2,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=78,
        parent_id=5,
        tree_path="0,1,5",
        name="部门删除",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:dept:delete",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=3,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=79,
        parent_id=6,
        tree_path="0,1,6",
        name="字典新增",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:dict:add",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=1,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=81,
        parent_id=6,
        tree_path="0,1,6",
        name="字典编辑",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:dict:edit",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=2,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=84,
        parent_id=6,
        tree_path="0,1,6",
        name="字典删除",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:dict:delete",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=3,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=88,
        parent_id=2,
        tree_path="0,1,2",
        name="重置密码",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:user:reset-password",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=4,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=89,
        parent_id=0,
        tree_path="0",
        name="功能演示",
        type=2,
        route_name=None,
        route_path="/function",
        component="Layout",
        perm=None,
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=12,
        icon="menu",
        redirect="",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=90,
        parent_id=89,
        tree_path="0,89",
        name="Websocket",
        type=1,
        route_name=None,
        route_path="/function/websocket",
        component="demo/websocket",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=3,
        icon="",
        redirect="",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=91,
        parent_id=89,
        tree_path="0,89",
        name="敬请期待...",
        type=2,
        route_name=None,
        route_path="other/:id",
        component="demo/other",
        perm=None,
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=4,
        icon="",
        redirect="",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=95,
        parent_id=36,
        tree_path="0,36",
        name="字典组件",
        type=1,
        route_name=None,
        route_path="dict-demo",
        component="demo/dictionary",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=4,
        icon="",
        redirect="",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=97,
        parent_id=89,
        tree_path="0,89",
        name="Icons",
        type=1,
        route_name=None,
        route_path="icon-demo",
        component="demo/icons",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=2,
        icon="el-icon-Notification",
        redirect="",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=102,
        parent_id=26,
        tree_path="0,26",
        name="document",
        type=3,
        route_name="",
        route_path="internal-doc",
        component="demo/internal-doc",
        perm=None,
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=1,
        icon="document",
        redirect="",
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=105,
        parent_id=2,
        tree_path="0,1,2",
        name="用户查询",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:user:query",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=0,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=106,
        parent_id=2,
        tree_path="0,1,2",
        name="用户导入",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:user:import",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=5,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=107,
        parent_id=2,
        tree_path="0,1,2",
        name="用户导出",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:user:export",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=6,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=108,
        parent_id=36,
        tree_path="0,36",
        name="增删改查",
        type=1,
        route_name=None,
        route_path="curd",
        component="demo/curd/index",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=0,
        icon="",
        redirect="",
        create_time=None,
        update_time=None,
        params=None
    )
    Menu.objects.create(
        id=109,
        parent_id=36,
        tree_path="0,36",
        name="列表选择器",
        type=1,
        route_name=None,
        route_path="table-select",
        component="demo/table-select/index",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=1,
        icon="",
        redirect="",
        create_time=None,
        update_time=None,
        params=None
    )
    Menu.objects.create(
        id=110,
        parent_id=0,
        tree_path="0",
        name="路由参数",
        type=2,
        route_name=None,
        route_path="/route-param",
        component="Layout",
        perm=None,
        always_show=1,
        keep_alive=1,
        visible=1,
        sort=11,
        icon="el-icon-ElementPlus",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=111,
        parent_id=110,
        tree_path="0,110",
        name="参数(type=1)",
        type=1,
        route_name=None,
        route_path="route-param-type1",
        component="demo/route-param",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=1,
        icon="el-icon-Star",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params="{\"type\": \"1\"}"
    )
    Menu.objects.create(
        id=112,
        parent_id=110,
        tree_path="0,110",
        name="参数(type=2)",
        type=1,
        route_name=None,
        route_path="route-param-type2",
        component="demo/route-param",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=2,
        icon="el-icon-StarFilled",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params="{\"type\": \"2\"}"
    )
    Menu.objects.create(
        id=117,
        parent_id=1,
        tree_path="0,1",
        name="系统日志",
        type=1,
        route_name="Log",
        route_path="log",
        component="system/log/index",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=6,
        icon="document",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=118,
        parent_id=0,
        tree_path="0",
        name="系统工具",
        type=2,
        route_name=None,
        route_path="/codegen",
        component="Layout",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=2,
        icon="menu",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=119,
        parent_id=118,
        tree_path="0,118",
        name="代码生成",
        type=1,
        route_name="Codegen",
        route_path="codegen",
        component="codegen/index",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=1,
        icon="code",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=120,
        parent_id=1,
        tree_path="0,1",
        name="系统配置",
        type=1,
        route_name="Config",
        route_path="config",
        component="system/config/index",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=7,
        icon="setting",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=121,
        parent_id=120,
        tree_path="0,1,120",
        name="系统配置查询",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:config:query",
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=1,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=122,
        parent_id=120,
        tree_path="0,1,120",
        name="系统配置新增",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:config:add",
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=2,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=123,
        parent_id=120,
        tree_path="0,1,120",
        name="系统配置修改",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:config:update",
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=3,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=124,
        parent_id=120,
        tree_path="0,1,120",
        name="系统配置删除",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:config:delete",
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=4,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=125,
        parent_id=120,
        tree_path="0,1,120",
        name="系统配置刷新",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:config:refresh",
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=5,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=126,
        parent_id=1,
        tree_path="0,1",
        name="通知公告",
        type=1,
        route_name="Notice",
        route_path="notice",
        component="system/notice/index",
        perm=None,
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=9,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=127,
        parent_id=126,
        tree_path="0,1,126",
        name="通知查询",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:notice:query",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=1,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=128,
        parent_id=126,
        tree_path="0,1,126",
        name="通知新增",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:notice:add",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=2,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=129,
        parent_id=126,
        tree_path="0,1,126",
        name="通知编辑",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:notice:edit",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=3,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=130,
        parent_id=126,
        tree_path="0,1,126",
        name="通知删除",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:notice:delete",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=4,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=133,
        parent_id=126,
        tree_path="0,1,126",
        name="通知发布",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:notice:publish",
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=5,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=134,
        parent_id=126,
        tree_path="0,1,126",
        name="通知撤回",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:notice:revoke",
        always_show=0,
        keep_alive=1,
        visible=1,
        sort=6,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=135,
        parent_id=1,
        tree_path="0,1",
        name="字典项",
        type=1,
        route_name="DictItem",
        route_path="dict-item",
        component="system/dict/dict-item",
        perm=None,
        always_show=0,
        keep_alive=1,
        visible=0,
        sort=6,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=136,
        parent_id=135,
        tree_path="0,1,135",
        name="字典项新增",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:dict-item:add",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=2,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=137,
        parent_id=135,
        tree_path="0,1,135",
        name="字典项编辑",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:dict-item:edit",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=3,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=138,
        parent_id=135,
        tree_path="0,1,135",
        name="字典项删除",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:dict-item:delete",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=4,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=139,
        parent_id=3,
        tree_path="0,1,3",
        name="角色查询",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:role:query",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=1,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=140,
        parent_id=4,
        tree_path="0,1,4",
        name="菜单查询",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:menu:query",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=1,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=141,
        parent_id=5,
        tree_path="0,1,5",
        name="部门查询",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:dept:query",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=1,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=142,
        parent_id=6,
        tree_path="0,1,6",
        name="字典查询",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:dict:query",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=1,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=143,
        parent_id=135,
        tree_path="0,1,135",
        name="字典项查询",
        type=4,
        route_name=None,
        route_path="",
        component=None,
        perm="sys:dict-item:query",
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=1,
        icon="",
        redirect=None,
        create_time=timezone.now(),
        update_time=timezone.now(),
        params=None
    )
    Menu.objects.create(
        id=144,
        parent_id=26,
        tree_path="0,26",
        name="后端文档",
        type=3,
        route_name=None,
        route_path="https://youlai.blog.csdn.net/article/details/145178880",
        component="",
        perm=None,
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=3,
        icon="document",
        redirect="",
        create_time=timezone.make_aware(datetime.strptime("2024-10-05 23:36:03", "%Y-%m-%d %H:%M:%S")),
        update_time=timezone.make_aware(datetime.strptime("2024-10-05 23:36:03", "%Y-%m-%d %H:%M:%S")),
        params=None
    )
    Menu.objects.create(
        id=145,
        parent_id=26,
        tree_path="0,26",
        name="移动端文档",
        type=3,
        route_name=None,
        route_path="https://youlai.blog.csdn.net/article/details/143222890",
        component="",
        perm=None,
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=4,
        icon="document",
        redirect="",
        create_time=timezone.make_aware(datetime.strptime("2024-10-05 23:36:03", "%Y-%m-%d %H:%M:%S")),
        update_time=timezone.make_aware(datetime.strptime("2024-10-05 23:36:03", "%Y-%m-%d %H:%M:%S")),
        params=None
    )
    Menu.objects.create(
        id=146,
        parent_id=36,
        tree_path="0,36",
        name="拖拽组件",
        type=1,
        route_name=None,
        route_path="drag",
        component="demo/drag",
        perm=None,
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=5,
        icon="",
        redirect="",
        create_time=timezone.make_aware(datetime.strptime("2025-03-31 14:14:45", "%Y-%m-%d %H:%M:%S")),
        update_time=timezone.make_aware(datetime.strptime("2025-03-31 14:14:52", "%Y-%m-%d %H:%M:%S")),
        params=None
    )
    Menu.objects.create(
        id=147,
        parent_id=36,
        tree_path="0,36",
        name="滚动文本",
        type=1,
        route_name=None,
        route_path="text-scroll",
        component="demo/text-scroll",
        perm=None,
        always_show=0,
        keep_alive=0,
        visible=1,
        sort=6,
        icon="",
        redirect="",
        create_time=timezone.make_aware(datetime.strptime("2025-03-31 14:14:49", "%Y-%m-%d %H:%M:%S")),
        update_time=timezone.make_aware(datetime.strptime("2025-03-31 14:14:56", "%Y-%m-%d %H:%M:%S")),
        params=None
    )

    # 插入角色数据
    Role.objects.create(
        id=1,
        name="超级管理员",
        code="ROOT",
        sort=1,
        status=1,
        data_scope=1,
        create_by=1,
        create_time=timezone.now(),
        update_by=1,
        update_time=timezone.now(),
        is_deleted=0
    )
    Role.objects.create(
        id=2,
        name="系统管理员",
        code="ADMIN",
        sort=2,
        status=1,
        data_scope=1,
        create_by=1,
        create_time=timezone.now(),
        update_by=1,
        update_time=timezone.now(),
        is_deleted=0
    )
    Role.objects.create(
        id=3,
        name="访问游客",
        code="GUEST",
        sort=3,
        status=1,
        data_scope=3,
        create_by=1,
        create_time=timezone.now(),
        update_by=1,
        update_time=timezone.now(),
        is_deleted=0
    )
    Role.objects.create(
        id=4,
        name="系统管理员1",
        code="ADMIN1",
        sort=4,
        status=1,
        data_scope=1,
        create_by=1,
        create_time=timezone.now(),
        update_by=1,
        update_time=timezone.now(),
        is_deleted=0
    )
    Role.objects.create(
        id=5,
        name="系统管理员2",
        code="ADMIN2",
        sort=5,
        status=1,
        data_scope=1,
        create_by=1,
        create_time=timezone.now(),
        update_by=1,
        update_time=timezone.now(),
        is_deleted=0
    )
    Role.objects.create(
        id=6,
        name="系统管理员3",
        code="ADMIN3",
        sort=6,
        status=1,
        data_scope=1,
        create_by=1,
        create_time=timezone.now(),
        update_by=1,
        update_time=timezone.now(),
        is_deleted=0
    )
    Role.objects.create(
        id=7,
        name="系统管理员4",
        code="ADMIN4",
        sort=7,
        status=1,
        data_scope=1,
        create_by=1,
        create_time=timezone.now(),
        update_by=1,
        update_time=timezone.now(),
        is_deleted=0
    )
    Role.objects.create(
        id=8,
        name="系统管理员5",
        code="ADMIN5",
        sort=8,
        status=1,
        data_scope=1,
        create_by=1,
        create_time=timezone.now(),
        update_by=1,
        update_time=timezone.now(),
        is_deleted=0
    )
    Role.objects.create(
        id=9,
        name="系统管理员6",
        code="ADMIN6",
        sort=9,
        status=1,
        data_scope=1,
        create_by=1,
        create_time=timezone.now(),
        update_by=1,
        update_time=timezone.now(),
        is_deleted=0
    )
    Role.objects.create(
        id=10,
        name="系统管理员7",
        code="ADMIN7",
        sort=10,
        status=1,
        data_scope=1,
        create_by=1,
        create_time=timezone.now(),
        update_by=1,
        update_time=timezone.now(),
        is_deleted=0
    )
    Role.objects.create(
        id=11,
        name="系统管理员8",
        code="ADMIN8",
        sort=11,
        status=1,
        data_scope=1,
        create_by=1,
        create_time=timezone.now(),
        update_by=1,
        update_time=timezone.now(),
        is_deleted=0
    )
    Role.objects.create(
        id=12,
        name="系统管理员9",
        code="ADMIN9",
        sort=12,
        status=1,
        data_scope=1,
        create_by=1,
        create_time=timezone.now(),
        update_by=1,
        update_time=timezone.now(),
        is_deleted=0
    )

    # 创建超级管理员用户
    user = User.objects.create(
        id=1,
        username="root",
        nickname="有来技术",
        gender=0,
        password="pbkdf2_sha256$870000$MYCo5sUmCNuqQemI8r2Fn4$QLPbnpt9Kxong+8yQ3LdK6n18i9tg1CPj+sl312b1KM=",  # 已经是加密密码
        email="youlaitech@163.com",
        mobile="18812345677",
        avatar="https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
        is_superuser=1,
        is_staff=1,
        is_active=1,
        status=1,
        date_joined=timezone.now(),
        is_deleted=0,
        openid=None
    )
    if user.id == 1:
        # 确保超级管理员有部门关联
        user.dept_id = 1
        user.save()
    elif user.id in [2, 3]:
        # 为其他用户设置部门
        user.dept_id = 1
        user.save()

    user = User.objects.create(
        id=2,
        username="admin",
        nickname="系统管理员",
        gender=1,
        password="pbkdf2_sha256$870000$MYCo5sUmCNuqQemI8r2Fn4$QLPbnpt9Kxong+8yQ3LdK6n18i9tg1CPj+sl312b1KM=",  # 已经是加密密码
        email="youlaitech@163.com",
        mobile="18812345678",
        avatar="https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
        is_superuser=0,
        is_staff=1,
        is_active=1,
        status=1,
        date_joined=timezone.now(),
        is_deleted=0,
        openid=None
    )
    if user.id == 1:
        # 确保超级管理员有部门关联
        user.dept_id = 1
        user.save()
    elif user.id in [2, 3]:
        # 为其他用户设置部门
        user.dept_id = 1
        user.save()

    user = User.objects.create(
        id=3,
        username="test",
        nickname="测试小用户",
        gender=1,
        password="pbkdf2_sha256$870000$MYCo5sUmCNuqQemI8r2Fn4$QLPbnpt9Kxong+8yQ3LdK6n18i9tg1CPj+sl312b1KM=",  # 已经是加密密码
        email="youlaitech@163.com",
        mobile="18812345679",
        avatar="https://foruda.gitee.com/images/1723603502796844527/03cdca2a_716974.gif",
        is_superuser=0,
        is_staff=0,
        is_active=1,
        status=1,
        date_joined=timezone.now(),
        is_deleted=0,
        openid=None
    )
    if user.id == 1:
        # 确保超级管理员有部门关联
        user.dept_id = 3
        user.save()
    elif user.id in [2, 3]:
        # 为其他用户设置部门
        user.dept_id = 3
        user.save()

    # 设置用户角色关联
    UserRole.objects.create(
        user_id=1,
        role_id=1
    )
    UserRole.objects.create(
        user_id=2,
        role_id=2
    )
    UserRole.objects.create(
        user_id=3,
        role_id=3
    )

    # 设置角色菜单关联
    RoleMenu.objects.create(
        role_id=2,
        menu_id=1
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=2
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=3
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=4
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=5
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=6
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=20
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=21
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=22
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=23
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=24
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=26
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=30
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=31
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=32
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=33
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=36
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=37
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=38
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=39
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=40
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=41
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=70
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=71
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=72
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=73
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=74
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=75
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=76
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=77
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=78
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=79
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=81
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=84
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=88
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=89
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=90
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=91
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=95
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=97
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=102
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=105
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=106
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=107
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=108
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=109
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=110
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=111
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=112
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=117
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=118
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=119
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=120
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=121
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=122
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=123
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=124
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=125
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=126
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=127
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=128
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=129
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=130
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=133
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=134
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=135
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=136
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=137
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=138
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=139
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=140
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=141
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=142
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=143
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=144
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=145
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=146
    )
    RoleMenu.objects.create(
        role_id=2,
        menu_id=147
    )

    # 创建系统配置
    SysConfig.objects.create(
        id=1,
        config_name="系统限流QPS",
        config_key="IP_QPS_THRESHOLD_LIMIT",
        config_value="10",
        remark="单个IP请求的最大每秒查询数（QPS）阈值Key",
        create_time=timezone.now(),
        create_by=1,
        update_time=None,
        update_by=None,
        is_deleted=0
    )


def remove_default_data(apps, schema_editor):
    # 获取模型
    Department = apps.get_model("system", "Department")
    Dictionary = apps.get_model("system", "Dictionary")
    DictionaryItem = apps.get_model("system", "DictionaryItem")
    Menu = apps.get_model("system", "Menu")
    Role = apps.get_model("system", "Role")
    RoleMenu = apps.get_model("system", "RoleMenu")
    User = apps.get_model("system", "User")
    UserRole = apps.get_model("system", "UserRole")
    SysConfig = apps.get_model("system", "SysConfig")
    Notice = apps.get_model("system", "Notice")
    UserNotice = apps.get_model("system", "UserNotice")

    # 清除所有初始数据，注意删除顺序要考虑外键约束
    UserNotice.objects.all().delete()
    Notice.objects.all().delete()
    SysConfig.objects.all().delete()
    UserRole.objects.all().delete()
    RoleMenu.objects.all().delete()
    User.objects.all().delete()
    Role.objects.all().delete()
    Menu.objects.all().delete()
    DictionaryItem.objects.all().delete()
    Dictionary.objects.all().delete()
    Department.objects.all().delete()


class Migration(migrations.Migration):
    dependencies = [
        ('system', '0001_initial'),
    ]

    operations = [
        migrations.RunPython(add_default_data, remove_default_data),
    ]
